1. Field of the Invention
The present invention relates to technology that compression-encodes image data.
2. Description of the Related Art
JPEG encoding may be mentioned as a known conventional method for encoding an image. JPEG encoding encodes blocks of 8×8 pixels in image data in units. It is assumed that all the processing described hereunder is executed taking this size block as a unit.
First, a discrete cosine transformation (DCT) is performed for input blocks to obtain 8×8 discrete cosine transform coefficients. Next, the discrete cosine transform coefficients are subjected to quantization using a quantization table. In this case, the value of an element of the quantization table is called a “quantization step width.” A quantization step width increases in size for discrete cosine transform coefficients of high frequency components. Quantization is performed by dividing the discrete cosine transform coefficients by the respectively corresponding quantization step width and rounding off fractional portions to the nearest integer. Consequently, the values after quantization become small with respect to high frequency components, and the occurrence frequency of zero increases. Next, separate encoding is performed for one direct current (DC) component and 63 alternating current (AC) components after quantization.
With respect to the DC component, Huffman coding is performed after executing differential predictive coding since the inter-block correlation is strong. Differential predictive coding is a method that encodes a difference with the immediately preceding value. Huffman coding is an encoding technique that assigns a short code to values with a high occurrence frequency and assigns a long code to values with a low occurrence frequency to ultimately shorten the overall code length.
For the AC components, Huffman coding is performed after performing run-length encoding. Run-length encoding is an encoding method in which the encoding rate increases proportionally to the continuation of one specific value. By performing zigzag scanning for the values after quantization, the encoding efficiency is improved by making a succession of 0 values of high frequency components.
As will be understood from the fact that JPEG encoding is employed in devices such as digital cameras, JPEG encoding is a favorable compression method for natural images. On the other hand, for images including characters or image lines, there is a problem that mosquito noise, caused by loss of high frequency components of an image, or block distortion caused by loss of high frequency components or a quantization error for a DC component, is likely to occur. For this reason, as a method for compressing image data with the resolution of a character or line image or the like maintained as it is, the image is divided into blocks as discrete cosine transform units. Thereafter, resolution information such as a character or line image of a previously designated color or density value is acquired in block units, and halftone information obtained by performing substitution processing at an appropriate value for the acquired region is encoded by discrete cosine transformation or the like. On the other hand, a method that encodes color information in block units by predictive coding or the like has been proposed.
In this case, an image is assumed to be a synthesized image of a natural image having relatively few high frequency components and a character or line image as binary-like information which locally has the same density value. In order to protect character or line image information from signal distortion generated upon compression/expansion of the image using discrete cosine transform encoding, the character and/or line image binary information is acquired in advance, and lossless encoding that is free from deterioration is performed for the binary information.
For example, Japanese Patent Application Laid-Open No. 4-326669 describes a method in which, for substitution processing to an acquisition region, substitution processing is performed that refers to a region other than the acquisition region within a block. More specifically, the average of a region other than the acquisition region is calculated by an average calculation unit, and substitution processing is performed with respect to the acquisition region using the obtained average. Alternatively, a method has been disclosed in which input pixels are delayed by one cycle, and substitution is performed with respect to the pixels of an acquisition region with the delayed pixels. With this kind of method, a spectrum after discrete cosine transformation is concentrated in a low frequency region and an effect is obtained that suppresses image quality deterioration after compression/expansion.
However, in the above described conventional image processing methods, the problem remains that when quantization step widths used when performing quantization after discrete cosine transformation are coarse, the possibility of a quantization error occurring is high, and that quantization error is one factor that causes block distortion in the image.
Further, when encoding a direct-current component value among the coefficients after discrete cosine transformation, encoding of the differential between the direct-current component value of the block of interest and the direct-current component value of the preceding block is performed. Because the direct current components of two blocks in a halftone image that does not include a character and/or line image are substantially the same value, that differential will be a small value, and the encoding efficiency is high.
However, if we focus on two neighboring blocks in a region that includes a character and/or line image on a halftone image, we find that in this case it is, instead, rare for the number of pixels of the character and/or line image included in the respective blocks to be the same, and inevitably the possibility that the difference between the direct current components of the two blocks will be zero is low. That is, the encoded data length of the direct current component is not minimized, and ample room for improvement remains.